# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=dbus-cpp
pkgver=5.0.3
pkgrel=13
pkgdesc="A header-only dbus-binding leveraging C++-11"
url="https://gitlab.com/ubports/core/lib-cpp/dbus-cpp"
arch="all"
license="LGPL-3.0-only"
depends_dev="boost-dev properties-cpp-dev"
makedepends="$depends_dev cmake cmake-extras dbus-dev libxml2-dev process-cpp-dev gtest-dev samurai"
checkdepends="dbus coreutils"
subpackages="$pkgname-dev"
source="https://gitlab.com/ubports/core/lib-cpp/dbus-cpp/-/archive/$pkgver/dbus-cpp-$pkgver.tar.gz
	cxx.patch
	0001-Add-missing-headers-for-GCC13.patch
	"
options="!check" # Tests are too unreliable to not fail randomly

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
03fcbfc856d58310a445ec02dc40e5b7a02a6ab7a5ee5455c8f56ff400a1820c9b62c7d7847eb8df8bad0e18704a35ce2a81c35864ca855cbc9a8e3965d21fc5  dbus-cpp-5.0.3.tar.gz
19134a16963834deffe57168048505a0485099b93c03e76f309bb7b3055fef70df8ae4e5aada0e5c8564349949aa89d926b27513978d055fe30dbaf345744228  cxx.patch
9125ebc5cfbd712b7007e19539de0d152802b3dd8a3fec2dc555f0cc1e54d327a5ccebfbbb572280f78dadf49c01cd6f508faf484d4a448dbbda9ad4df0e17bf  0001-Add-missing-headers-for-GCC13.patch
"
